﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.TcCommands.CApMFGSearchTypeFilter
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Tecnomatix.Engineering;
using Tecnomatix.Planning;


namespace DnProcessSimulateCommands.TcCommands;

internal class CApMFGSearchTypeFilter : ITxTypeFilter
{
  private TxTypeFilter m_modelObjectTypesFilter;

  public CApMFGSearchTypeFilter()
  {
    this.m_modelObjectTypesFilter = new TxTypeFilter(new List<Type>()
    {
      typeof (TxTcProcess),
      typeof (ITxTcOperation),
      typeof (TxCompoundPart),
      typeof (TxPlanningPart)
    }.ToArray<Type>());
  }

  public bool DoesPassFilter(ITxObject obj)
  {
    bool flag = this.DoesPassFilter(obj.GetType());
    if (!flag && obj is ITxProcessModelObject processModelObject && processModelObject.PlanningRepresentation != null)
      flag = this.DoesPassFilter(((ITxObject) processModelObject.PlanningRepresentation).GetType());
    return flag;
  }

  public bool DoesPassFilter(Type type) => this.m_modelObjectTypesFilter.DoesPassFilter(type);

  public TxObjectList Filter(TxObjectList objects)
  {
    TxObjectList txObjectList = new TxObjectList();
    foreach (ITxObject itxObject in (Collection<ITxObject>) objects)
    {
      if (this.DoesPassFilter(itxObject))
        ((Collection<ITxObject>) txObjectList).Add(itxObject);
    }
    return txObjectList;
  }
}
